# -*- coding: utf-8 -*-


import urllib
import urllib.request
import json


def open_site():
    url = "http://fundf10.eastmoney.com/jjjz_202101.html"
    header = {
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36"
    }
    request = urllib.request.Request(url=url, headers=header)
    response = urllib.request.urlopen(request)
    html_text = response.read().decode("utf-8")
    print(html_text)
    # 保存文件
    # html_file = open("html.html", "w")
    # html_file.write(html_text)

    # html = BeautifulSoup(page, "lxml")
    # lsjz = html.select('table[class="lsjz"]')
    # print(lsjz)
    # for jz in lsjz:
    #     tor = jz.select('tr[class="tor"]')
    #     print(tor)


    # even = html.select('tr[class="even"]')
    # odd = html.select('tr[class="odd"]')
    # all = even + odd

    # items = []
    # for a in all:
    #     item = {}

    #     workName = a.select('td a')[0].get_text()
    #     detailLink = a.select('td a')[0].attrs['href']
    #     workCatalog = a.select('td')[1].get_text()
    #     recruitNumber = a.select('td')[2].get_text()
    #     workLocation = a.select('td')[3].get_text()
    #     publishTime = a.select('td')[4].get_text()

    #     item['workName'] = workName
    #     item['detailLink'] = url + detailLink
    #     item['workCatalog'] = workCatalog
    #     item['recruitNumber'] = recruitNumber
    #     item['workLocation'] = workLocation
    #     item['publishTime'] = publishTime

    #     items.append(item)

    # fo = open("position.json", "w")
    # fo.write(json.dumps(items, ensure_ascii=False).encode("utf-8"))
    # fo.close()



if __name__ == "__main__":

    open_site()



    pass